<template>
  <vxe-table
    id="iStudentHonorArchive-table"
    ref="tableRef"
    v-loading="loading"
    :data="list"
    stripe
    :column-config="{ resizable: true }"
    :size="vxeTableSize"
  >
    <vxe-column :title="t('common.index')" type="seq" field="seq" width="60" align="center" />
    <vxe-column
      :title="t('studentHonorArchive.fields.reviewSubmitTime')"
      field="reviewSubmitTime"
      align="center"
      show-header-overflow
      show-overflow
      min-width="100"
      :formatter="vxeDateFormatter"
    />
    <vxe-column
      :title="t('studentHonorArchive.fields.reviewStatus')"
      field="reviewStatus"
      align="center"
      show-header-overflow
      show-overflow
      min-width="100"
    />
    <vxe-column
      :title="t('studentHonorArchive.fields.reviewerName')"
      field="reviewerName"
      align="center"
      show-header-overflow
      show-overflow
      min-width="100"
    />
    <vxe-column
      :title="t('studentHonorArchive.fields.reviewTime')"
      field="reviewTime"
      align="center"
      show-header-overflow
      show-overflow
      min-width="100"
      :formatter="vxeDateFormatter"
    />
    <vxe-column
      :title="t('studentHonorArchive.fields.reviewComments')"
      field="reviewComments"
      align="center"
      show-header-overflow
      show-overflow
      min-width="100"
    />
    <vxe-column
      :title="t('common.operate')"
      field="operator"
      align="center"
      fixed="right"
      width="80"
    >
      <template #default="scope">
        <el-button link type="primary" @click="handleViewDetail(scope.row.id)">
          {{ t('action.detail') }}
        </el-button>
      </template>
    </vxe-column>
  </vxe-table>

  <!-- 表单弹窗：添加/修改 -->
  <StudentHonorArchiveForm ref="formRef" />
</template>

<script setup lang="ts">
import { vxeDateFormatter } from '@/utils/formatTime'
import { StudentHonorArchiveApi, StudentHonorArchiveVO } from '@/api/core/studenthonorarchive'
import StudentHonorArchiveForm from './StudentHonorArchiveForm.vue'
import { useAppStore } from '@/store/modules/app'

/** 荣誉奖项审核归档 列表 */
defineOptions({ name: 'StudentHonorArchive' })

const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const list = ref<StudentHonorArchiveVO[]>([]) // 列表的数据

const props = defineProps<{
  dataId: string
}>()

const appStore = useAppStore()
const vxeTableSize = computed(() => appStore.getCurrentSizeVxe)

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    list.value = await StudentHonorArchiveApi.getStudentHonorArchiveList(props.dataId)
  } finally {
    loading.value = false
  }
}
/** 添加/修改操作 */
const formRef = ref<InstanceType<typeof StudentHonorArchiveForm>>()
const handleViewDetail = (id: number) => {
  formRef.value?.open(id)
}

/** 初始化 **/
onMounted(() => {
  getList()
})
</script>
